package junit.base;

import org.junit.After;
import org.junit.Before;
import org.junit.Test;

/**
 * Created by zhaott on 2018/9/18.
 */
public class JunitDemo03 {

    //开始时间
    long startTimeMillis;

    //结束时间
    long endTimeMillis;

    @Before
    public void before(){
        startTimeMillis=System.currentTimeMillis();
    }

    @After
    public void after(){
        endTimeMillis= System.currentTimeMillis();
        System.out.println("【耗时】"+(endTimeMillis-startTimeMillis));
    }

    @Test
    public void demo03(){
        this.query();
    }

    private void query(){
        try {
            Thread.sleep((long) (Math.random()*1000));
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }

}
